﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using GAE_PI.Models;
using System.Data.Objects;
using GAE_PI.Exceptions;

namespace GAE_PI.Controllers
{
    public class AuthentificationController : Controller
    {

        //
        // GET: /Authentification/
        public ActionResult Authentification()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Authentification(MyLogOnModel model)
        {
            try
            {
                DBModel.getDBM().authentification(model);
                return RedirectToAction("ConsulterActivites", "ConsulterActivites");
            }
            catch(GAEException e)
            {
                return View("Error", e.errorModel);
            }
              
        }

        public ActionResult Deconnexion()
        {
            Session.Abandon();
            return RedirectToAction("ConsulterActivites", "ConsulterActivites");
        }
        


    }
}
